<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>修改发票数量</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/layui/css/layui.css">
</head>
<body>
<form class="layui-form">
	<div class="layui-row">
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">发票数量:</label>
				<div class="layui-input-block">
					<input type="text" name="invoiceNum" id="invoiceNum" lay-verify="required"
						value="${invoiceNum}" autocomplete="off" onkeyup="value=value.replace(/[^\d]/g,'') " ng-pattern="/[^a-zA-Z]/" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">所属区域:</label>
				<div class="layui-input-block">
					<input type="text" disabled="disabled" class="layui-input" value="${areaName}">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-xs10 layui-col-sm10 layui-col-md10">
				<label class="layui-form-label">发票类型:</label>
				<div class="layui-input-block">
					<input type="text" disabled="disabled" class="layui-input" value="${typeName }">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" class="layui-btn" id="submit_btn">立即提交</button>
			</div>
		</div>
	</div>
</form>
</body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/lib/layui/layui.all.js"></script>
<script>
var ctx = "${pageContext.request.contextPath}";
var layer = layui.layer;
var invoiceId = '${invoiceId}';
$(function(){
	$("#submit_btn").on("click",function(){
		var invoiceNum = $("#invoiceNum").val();
		
		if(!invoiceNum){
			layer.msg("信息都为必填项!");
			return false;
		}
		
		if(!Number(invoiceNum)){
			layer.msg("数量必须为数字!");
			return false;
		}
		
		var index = layer.open({
		  type: 3
		});
		$.ajax({
		  type: 'POST',
		  url: ctx+"/finance/updateNum",
		  data: {
			  invoiceNum:invoiceNum,
			  invoiceId:invoiceId
		  },
		  success: function(data){
			  layer.close(index);
			  if(data && data.state){
				  layer.msg('提交成功!!');
				  var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				  parent.layer.close(index);
			  }
		  },
		  error:function(data){
			  layer.close(index);
			  console.log(data);
		  }
		});
	});
	
});





</script>
</html>